document.write("<link rel='stylesheet' href='http://gh.120huamei.com/static/css/jquery.datetimepicker.css' type='text/css' />");

document.write("<script src='http://gh.120huamei.com/static/js/jquery.datetimepicker.js'></script>");



//科室信息加载
function keshiload(){
	var data={};
	data.type="ksid";
	data.domain=window.location.host;
	$("select[name='gh_disease']").html("");
	$.getJSON("http://gh.120huamei.com/home/yiyuan",data,function(response){
		if(response.result){
			$("select[name='gh_disease']").append("<option value='no'>请选择科室</option>");
			$.each(response.data.list,function(i,vi){
				$("select[name='gh_disease']").append("<option value="+vi.id+">"+vi.name+"</option>");
			})			
			$("select[name='gh_disease']").show();
		}		
	});

}

keshiload();

$(function(){
	$("input[name='gh_submit']").on("click",function(){
		var data={};
		data.username=$("input[name='gh_name']").val();
		data.phone=$("input[name='gh_tel']").val();
		data.yytime=$("input[name='gh_date']").val();
		data.ksid=$("select[name='gh_disease']").val();
		data.remark=$("textarea[name='gh_des']").val();
		data.domain=window.location.host;

		if(data.username==""){
			alert("请填写用户名");
			return;
		}
		
		if(data.phone==""){
			alert("请填写手机号");
			return;
		}else{
			if(isNaN(data.phone)){
				alert("请填写正确的手机号");
				return;
			}else{
				if(data.phone.length!=11){
					alert("请输入正确的手机号");
					return;
				}
			}
		}

		if(data.yytime==""){
			alert("请选择预约时间");
			return;
		}

		if(data.ksid==""||data.ksid=="no"){
			alert("请选择科室");
			return;
		}

		$.getJSON("http://gh.120huamei.com/home/ghsubmittwo",data,function(response){
			if(response.result){
				alert(response.msg);
			}else{
				alert(response.msg);
			}
		})

	})
})

//时间插件
document.write("<script>$('#gh_date').datetimepicker({lang:'ch',timepicker:false,format:'Y/m/d',minDate:'-1970/01/01',maxDate:'+1970/01/14'});<\/script>");